package com.navinfo.collect.library.map

import java.io.Serializable


class MapManager private constructor() : Serializable {
    //private constructor()构造器私有化
    private lateinit var mMapView: NIMapView;
    fun init(mapView: NIMapView) {
        this.mMapView = mapView
        mMapView.showZoomControls(false)
    }

    private fun readResolve(): Any {//防止单例对象在反序列化时重新生成对象
        return instance
    }

    companion object {
        //通过@JvmStatic注解，使得在Java中调用instance直接是像调用静态函数一样，
        //NIFragmentManager.getInstance(),如果不加注解，在Java中必须这样调用: NIFragmentManager.Companion.getInstance().
        @JvmStatic
        //使用lazy属性代理，并指定LazyThreadSafetyMode为SYNCHRONIZED模式保证线程安全
        val instance: MapManager by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { MapManager() }
    }
}